<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/html/js/getParameter.js"></script>
    <script type="text/javascript" src="/html/js/jquery.js"></script>
    <script type="text/javascript" src="../../js/api.js"></script>
    <script type="text/javascript" src="../../js/axios.js"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>仓库管理</li>
    <li>仓库管理</li>
    <li>修改仓库</li>
  </ul>
</div>
<div class="formbody">
    <form id="fo3">
  <div class="formtitle"><span>仓库信息</span></div>
  <ul class="forminfo">
    <li>
      <label>仓库名称</label>
      <input name="cName" type="text" value="南京21号仓库" class="dfinput" id="c1"/>
      <i>必填，不能超过30个字符</i>
    </li>
    <li>
      <label>仓库地址</label>
      <input name="cAddress" type="text" value="江苏南京苏铺路180号泸州花园7栋3单元1801室" class="dfinput" id="c2"/>
      <i>必填，不能超过300个字符</i>
    </li>
    <li>
      <label>所属区域</label>
      <select name="provinceId" class="dfselect" id="c3">
          <option value="0">请选择</option>
          <option value="1">北京</option>
          <option value="2">江苏</option>
      </select>
      省
      <select name="cityId" class="dfselect" id="c4">
          <option value="0">请选择</option>
          <option value="2">北京</option>
          <option value="3" selected="selected">南京</option>
          <option value="4">天津</option>
      </select>
      市
      <i>必选</i>
    </li>
    <li>
      <label>负责人</label>
      <select name="userId" class="dfselect" id="c5">
          <option value="0">请选择</option>
          <option value="1" selected="selected">周仓</option>
          <option value="2">廖化</option>
          <option value="3">张昭</option>
      </select>
       <i>只能是财务部仓库管理员职位</i>
    </li>
    <li>
      <label>联系方式</label>
      <input name="phone" type="text" value="17370899727" class="dfinput" id="c6"/>
       <i>必填，不能超过30个字符</i>
    </li>
    <li>
      <label>描述</label>
      <textarea name="details" class="textinput" id="c7">天下第一仓</textarea>
      <i>可选</i>
    </li>
    <li>
      <label>状态</label>
      <select name="state" class="dfselect" id="c8">
          <option value="1">可用</option>
          <option value="2">不可用</option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>创建人</label>
      <input name="usersId" type="text" value="马云" readonly="readonly" class="roinput" id="c9"/>
      <i>不能编辑</i>
    </li>
    <li>
      <label>创建时间</label>
      <input name="creationTime" type="text" value="2017-11-18 15:36:10" readonly="readonly" class="roinput" id="c10"/>
      <i>不能编辑</i>
    </li>
    <li id="submit_update">
      <label>&nbsp;</label>
      <input name="" type="button" class="btn" value="确定" onclick="updateData()"/>
      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='storageList.html'"/>
    </li>
  </ul>
 </form>
</div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        var id = getParameter("id");
        var ID = 'id='+id
        axiosRequest("post", "/warehouse/queryWare", ID)
            .then((res) => {
                var ware = res.data;
                $("#c1").val(ware.cName);
                $("#c2").val(ware.cAddress);
                // $("#c3").val(ware.province.id)
                // $("#c4").val(ware.city.id);
                // $("#c5").val(ware.user.uName);
                $("#c6").val(ware.user.uTelephone);
                $("#c7").val(ware.details);
                $("#c8").val(ware.state);
                $("#c9").val(ware.creator.uId);
                $("#c10").val(ware.creationTime);
                queryUsers(ware.user.uId)
                addressMenuInitOfDefault($("#c3"), $("#c4"), ware.province.id, ware.city.id)
            });
    });
    function queryUsers(uid) {
        var dataArr = "deptId="+3+"&jobId="+8
        axiosRequest("post", "/warehouse/queryUsers",dataArr)
            .then((res) => {
                var lis = "<option value=\""+0+"\">请选择</option>"
                for (var i = 0; i < res.data.length; i++) {
                    var li;
                    if (uid==res.data[i].uId){
                        li = "<option value=\""+res.data[i].uId+"\" selected>"+res.data[i].uName+"</option>"
                    }else{
                        li = "<option value=\""+res.data[i].uId+"\">"+res.data[i].uName+"</option>"
                    }
                    lis+=li;
                }
                $("#c5").html(lis);
            })
    }
    function updateData() {
        var id = getParameter("id");
        var ID = 'id='+id
        var dataArr = ID+"&"+$("#fo3").serialize();
        console.log(dataArr)
        axiosRequest("post", "/warehouse/updateWarehouse",dataArr)
            .then((res) => {
                window.location.href = "./storageList.html"
            });
    }
</script>
